package com.more.offer.threadtest.semaphoretest;

import java.util.concurrent.Semaphore;

/**
 * @author pinoc
 * @date 2022/6/17
 */
public class SemaphoreSingleTest {

	private Semaphore semaphore = new Semaphore(1);

	public SemaphoreSingleTest() {
	}

	public void test() {
		 try {
			 semaphore.acquire();
			 System.out.println(Thread.currentThread().getName() + " start ---");
			 Thread.sleep(2000);
			 System.out.println(Thread.currentThread().getName() + " end ---");
			 semaphore.release();
		 } catch (InterruptedException e) {
			 e.printStackTrace();
		 }
	 }

}
